<template>
    <!-- <div class="right-menu-item hover-effect"> -->
    <!-- <div @click="feedbackTap">
            <svg-icon class-name="size-icon" icon-class="bianji2" />利用效果反馈

        </div> -->

    <el-dialog :v-if="feedbackOpen" :title="dataRow.feedbackId != undefined ? '利用效果详情' : '利用效果反馈'" :visible.sync="feedbackOpen"
        width="55%" :before-close="closeDelDialog" append-to-body>
        <div>
            <el-col :span="24" class="transf-title" style="margin-bottom:20px">档案利用效果反馈表</el-col>
            <table border="1" cellpadding="0" cellspacing="0" class="orderBorder">
                <tr>
                    <td style="width:140px;">反馈部门</td>
                    <td>
                        <el-input v-model="form.deptName" placeholder="" type="textarea"
                                  :autosize="{ minRows: 1, maxRows: 2 }" style="height: 60px;"></el-input>
                    </td>
                    <td style="width:140px;">反馈日期</td>
                    <td>
                        <el-input v-model="form.feedbackDate" placeholder="" type="textarea"
                                  :autosize="{ minRows: 1, maxRows: 2 }" style="height: 60px;"></el-input>
                    </td>
                    <td style="width:140px;">反馈人</td>
                    <td>
                        <el-input v-model="form.feedbackName" placeholder="" type="textarea"
                                  :autosize="{ minRows: 1, maxRows: 2 }" style="height: 60px;"></el-input>
                    </td>
                </tr>
                <tr>
                    <td>利用档案名称</td>
                    <td colspan="5">
                        <el-input v-model="form.daTitle" placeholder="" type="textarea"
                                  :autosize="{ minRows: 1, maxRows: 2 }" style="height: 60px;"></el-input>
                    </td>
                </tr>
                <tr>
                    <td>利用原因</td>
                    <td colspan="2">
                        <el-select disabled v-model="form.utilizeReasons" placeholder="请选择" clearable style="width: 100%">
                          <el-option v-for="dict in dict.type.LYMD" :key="dict.value" :label="dict.label"
                                     :value="dict.value" />
                        </el-select>
                    </td>
                    <td>利用方式</td>
                    <td colspan="2">
                        <el-radio-group disabled v-model="form.useWay">
                          <el-radio :label="'1'">复印件</el-radio>
                          <el-radio :label="'2'">原件</el-radio>
                        </el-radio-group>
                    </td>
                </tr>
                <tr>
                    <td>利用情况记录</td>
                    <td colspan="5">
                        <el-input v-model="form.situationRecord" placeholder="" type="textarea"
                            :autosize="{ minRows: 2, maxRows: 4 }" style="height: 100px;"></el-input>
                    </td>
                </tr>
                <tr>
                    <td>社会效益</td>
                    <td colspan="5">
                        <el-input v-model="form.socialBenrfit" placeholder="" type="textarea"
                            :autosize="{ minRows: 2, maxRows: 4 }" style="height: 100px;"></el-input>
                    </td>
                </tr>
                <tr>
                    <td>经济效益</td>
                    <td colspan="5">
                        <el-input v-model="form.economicBenefits" placeholder="" type="textarea"
                            :autosize="{ minRows: 2, maxRows: 4 }" style="height: 100px;"></el-input>
                    </td>
                </tr>
                <tr>
                    <td>备注</td>
                    <td colspan="5">
                        <el-input v-model="form.remark" placeholder="" type="textarea"
                            :autosize="{ minRows: 2, maxRows: 4 }" style="height: 100px;"></el-input>
                    </td>
                </tr>

            </table>

        </div>
        <div slot="footer" class="dialog-footer" style="display: flex;justify-content: center;">
            <el-button type="primary" @click="submitForm"
                v-if="dataRow.feedbackId == undefined || dataRow.feedbackId == 'null' || dataRow.feedbackId == ''">确 定</el-button>
            <el-button @click="closeDelDialog">取 消</el-button>
        </div>
    </el-dialog>
    <!-- </div> -->
</template>
<script>
import {evaluation, evaluationinfo, getArchiveBorrowByBorrowId} from "@/api/archive/feedbackManagement/index.js";
export default {
    archive_Dicts: ['LYMD'],
    props: ['feedbackOpen', 'dataRow'],
    watch: {
        dataRow: {
            handler(valNew) {
                this.form["borrowId"] = valNew.borrowId;
                if (valNew.feedbackId != undefined) { //如果反馈id有值 ，就是查看详情
                    evaluationinfo(valNew.feedbackId).then(res => {
                        if (res.code == "200") {
                            this.form = res.data;
                        }
                    })
                }
            },
            immediate: true
        }
    },
    data() {
        return {
            form: {
                "deptName": undefined,
                "feedbackDate": undefined,
                "feedbackName": undefined,
                "daTitle": undefined,
                "utilizeReasons": undefined,
                "useWay": undefined,
                "situationRecord": undefined,
                "socialBenrfit": undefined,
                "economicBenefits": undefined
            }
        }
    },
    created() {
        const date = new Date()
        const year = date.getFullYear() + ""
        const month = ('0' + (date.getMonth() + 1)).slice(-2)
        const day = ('0' + date.getDate()).slice(-2)
        this.form.feedbackDate = year + "-" + month + "-" + day;
        if (this.dataRow.feedbackId == undefined){
          getArchiveBorrowByBorrowId(this.dataRow.borrowId).then(res => {
            this.loading = false;
            if (res.code == "200") {
              console.log(this.dataRow,"sinan");
              this.form.deptName = res.data.deptName;
              this.form.feedbackName = res.data.feedbackName;
              this.form.daTitle = res.data.daTitle;
              this.form.utilizeReasons = this.dataRow.yongtu;
              if("E"==this.dataRow.daType){
                //电子档案默认为原件
                this.form.useWay = "2";
              }else{
                this.form.useWay = this.dataRow.liyongfangshi;
              }
              this.form.feedbackDate = year + "-" + month + "-" + day;
            }
          })
        }
    },
    methods: {
        closeDelDialog() {
            var that = this;

            this.$emit("closeDelDialogFeedback")
        },

        //提交
        submitForm() {
            var that = this;


            if (this.form.deptName == undefined || this.form.deptName == '') {
                this.$modal.msgWarning('请输入反馈部门')
                return false
            }
            if (this.form.feedbackDate == undefined || this.form.feedbackDate == '') {
                this.$modal.msgWarning('请输入反馈日期')
                return false
            }
            if (this.form.feedbackName == undefined || this.form.feedbackName == '') {
                this.$modal.msgWarning('请输入反馈人')
                return false
            }
            if (this.form.daTitle == undefined || this.form.daTitle == '') {
                this.$modal.msgWarning('请输入利用档案名称')
                return false
            }
            if (this.form.utilizeReasons == undefined || this.form.utilizeReasons == '') {
                this.$modal.msgWarning('请输入利用原因')
                return false
            }

            // if (this.form.useWay == undefined || this.form.useWay == '') {
            //     this.$modal.msgWarning('请输入利用方式')
            //     return false
            // }
            if (this.form.situationRecord == undefined || this.form.situationRecord == '') {
                this.$modal.msgWarning('请输入利用情况记录')
                return false
            }
            if (this.form.socialBenrfit == undefined || this.form.socialBenrfit == '') {
                this.$modal.msgWarning('请输入社会效益')
                return false
            }

            if (this.form.economicBenefits == undefined || this.form.economicBenefits == '') {
                this.$modal.msgWarning('请输入经济效益哦')
                return false
            }

            this.$modal.loading("加载中...")
            evaluation(this.form).then(res => {
                if (res.code == "200") {
                    that.$modal.msgSuccess("操作成功")
                    this.feedbackOpen = false;
                    that.$modal.closeLoading();
                    this.$emit("submitFormFeedback")
                }
            }).catch(res => {
                that.$modal.closeLoading();
                this.$emit("submitFormFeedback")
            })
        }
    }
}
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__body {
    padding: 0 20px 10px !important;
}

.steps-action {
    margin-top: 24px;
}

.printMain {
    display: flex;
    flex-direction: row;
}

::v-deep .el-dialog {
    display: flex;
    flex-direction: column;
    margin: 0 !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: calc(100% - 30px);
    max-width: calc(100% - 30px);
}

::v-deep .el-dialog .el-dialog__body {
    flex: 1;
    overflow: auto;
}



.orderBorder {
    width: 85%;
    margin: 0px auto;
}

.orderBorder td {
    height: 42px;
    line-height: 42px;
    text-align: center;
    border: rgb(42, 41, 41) 1px solid;
    padding: 5px;
}

.transbz {
    width: 60%;
    margin: 0 auto;
}

::v-deep .orderBorder input {
    border: 0 !important;
    width: 100%
}

::v-deep input::-webkit-outer-spin-button,
::v-deep input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
}

::v-deep input[type="number"] {
    -moz-appearance: textfield;
}

.transf-title {
    text-align: center;
    line-height: 55px;
    font-weight: bold;
    font-size: 28px;
}

.ymd {
    padding: 0;
    margin: 0;
    display: flex;
    width: 80%;
    text-align: right;
}

::v-deep .textNSME input {
    text-align: right !important;
}

.pinput {
    display: flex;
    flex-direction: row;
    line-height: 42px;
    align-items: center;
}

table td>div {
    width: -webkit-fill-available !important;
}

::v-deep .el-textarea__inner {
    height: 100% !important;
    border: 0 !important;
}
</style>
